Ubuntu 16.04
Sponsored Link

OpenStack Queens : How to use Barbican
2018/03/18
 
How to use the OpenStack Key Manager Service (Barbican).
This example is based on the emvironment like follows.
     ------------+---------------------------+---------------------------+------------
                 |                           |                           |
             eth0|10.0.0.30              eth0|10.0.0.50              eth0|10.0.0.51
     +-----------+-----------+   +-----------+-----------+   +-----------+-----------+
     |    [ Control Node ]   |   |    [ Network Node ]   |   |    [ Compute Node ]   |
     |                       |   |                       |   |                       |
     |  MariaDB    RabbitMQ  |   |     Cinder-Volume     |   |        Libvirt        |
     |  Memcached  httpd     |   |        L2 Agent       |   |     Nova Compute      |
     |  Keystone   Glance    |   |        L3 Agent       |   |      Open vSwitch     |
     |  Nova API             |   |     Metadata Agent    |   |        L2 Agent       |
     |  Neutron Server       |   |                       |   |                       |
     |  Metadata Agent       |   |                       |   |                       |
     |  Cinder API           |   |                       |   |                       |
     |  Barbican API         |   |                       |   |                       |
     +-----------------------+   +-----------------------+   +-----------------------+

[1] This is the basic usage of Barbican.
# store a key : --name [key's name] --payload [key's data]

root@dlp ~(keystone)#
openstack secret store --name secret01 --payload secretkey

+---------------+-----------------------------------------------------------------------+
| Field         | Value                                                                 |
+---------------+-----------------------------------------------------------------------+
| Secret href   | http://10.0.0.30:9311/v1/secrets/9a1338fa-398b-4391-ac2c-65d540ccd704 |
| Name          | secret01                                                              |
| Created       | None                                                                  |
| Status        | None                                                                  |
| Content types | None                                                                  |
| Algorithm     | aes                                                                   |
| Bit length    | 256                                                                   |
| Secret type   | opaque                                                                |
| Mode          | cbc                                                                   |
| Expiration    | None                                                                  |
+---------------+-----------------------------------------------------------------------+

# show keys list

root@dlp ~(keystone)#
openstack secret list

+-----------------------------------------------------------------------+----------
| Secret href                                                           | Name     
+-----------------------------------------------------------------------+----------
| http://10.0.0.30:9311/v1/secrets/9a1338fa-398b-4391-ac2c-65d540ccd704 | secret01 
+-----------------------------------------------------------------------+----------
+---------------------------+--------+-----------------------------+-----------
| Created                   | Status | Content types               | Algorithm 
+---------------------------+--------+-----------------------------+-----------
| 2018-03-20T00:57:48+00:00 | ACTIVE | {u'default': u'text/plain'} | aes       
+---------------------------+--------+-----------------------------+-----------
+------------+-------------+------+------------+
| Bit length | Secret type | Mode | Expiration |
+------------+-------------+------+------------+
|        256 | opaque      | cbc  | None       |
+------------+-------------+------+------------+

# get metadata of a key

root@dlp ~(keystone)#
openstack secret get http://10.0.0.30:9311/v1/secrets/9a1338fa-398b-4391-ac2c-65d540ccd704

+---------------+-----------------------------------------------------------------------+
| Field         | Value                                                                 |
+---------------+-----------------------------------------------------------------------+
| Secret href   | http://10.0.0.30:9311/v1/secrets/9a1338fa-398b-4391-ac2c-65d540ccd704 |
| Name          | secret01                                                              |
| Created       | 2018-03-20T00:57:48+00:00                                             |
| Status        | ACTIVE                                                                |
| Content types | {u'default': u'text/plain'}                                           |
| Algorithm     | aes                                                                   |
| Bit length    | 256                                                                   |
| Secret type   | opaque                                                                |
| Mode          | cbc                                                                   |
| Expiration    | None                                                                  |
+---------------+-----------------------------------------------------------------------+

# get data of a key

root@dlp ~(keystone)#
openstack secret get http://10.0.0.30:9311/v1/secrets/9a1338fa-398b-4391-ac2c-65d540ccd704 --payload

+---------+-----------+
| Field   | Value     |
+---------+-----------+
| Payload | secretkey |
+---------+-----------+

# generate and store a key

root@dlp ~(keystone)#
openstack secret order create --name secret02 --algorithm aes --bit-length 256 \
--mode cbc --payload-content-type application/octet-stream key

+----------------+----------------------------------------------------------------------+
| Field          | Value                                                                |
+----------------+----------------------------------------------------------------------+
| Order href     | http://10.0.0.30:9311/v1/orders/a795afdb-1bf8-4afd-a1cc-c069a33e0057 |
| Type           | Key                                                                  |
| Container href | N/A                                                                  |
| Secret href    | None                                                                 |
| Created        | None                                                                 |
| Status         | None                                                                 |
| Error code     | None                                                                 |
| Error message  | None                                                                 |
+----------------+----------------------------------------------------------------------+

# show generated keys list

root@dlp ~(keystone)#
openstack secret order list

+----------------------------------------------------------------------+------+----------------
| Order href                                                           | Type | Container href 
+----------------------------------------------------------------------+------+----------------
| http://10.0.0.30:9311/v1/orders/a795afdb-1bf8-4afd-a1cc-c069a33e0057 | Key  | N/A            
+----------------------------------------------------------------------+------+----------------
+-----------------------------------------------------------------------+---------------------------
| Secret href                                                           | Created                   
+-----------------------------------------------------------------------+---------------------------
| http://10.0.0.30:9311/v1/secrets/ccd903fb-2b20-45bb-945d-2acb8f20f20c | 2018-03-20T00:59:44+00:00 
+-----------------------------------------------------------------------+---------------------------
+--------+------------+---------------+
| Status | Error code | Error message |
+--------+------------+---------------+
| ACTIVE | None       | None          |
+--------+------------+---------------+

# show a generated key

root@dlp ~(keystone)#
openstack secret order get http://10.0.0.30:9311/v1/orders/a795afdb-1bf8-4afd-a1cc-c069a33e0057

+----------------+-----------------------------------------------------------------------+
| Field          | Value                                                                 |
+----------------+-----------------------------------------------------------------------+
| Order href     | http://10.0.0.30:9311/v1/orders/a795afdb-1bf8-4afd-a1cc-c069a33e0057  |
| Type           | Key                                                                   |
| Container href | N/A                                                                   |
| Secret href    | http://10.0.0.30:9311/v1/secrets/ccd903fb-2b20-45bb-945d-2acb8f20f20c |
| Created        | 2018-03-20T00:59:44+00:00                                             |
| Status         | ACTIVE                                                                |
| Error code     | None                                                                  |
| Error message  | None                                                                  |
+----------------+-----------------------------------------------------------------------+

# show metadata of a generated key

root@dlp ~(keystone)#
openstack secret get http://10.0.0.30:9311/v1/secrets/ccd903fb-2b20-45bb-945d-2acb8f20f20c

+---------------+-----------------------------------------------------------------------+
| Field         | Value                                                                 |
+---------------+-----------------------------------------------------------------------+
| Secret href   | http://10.0.0.30:9311/v1/secrets/ccd903fb-2b20-45bb-945d-2acb8f20f20c |
| Name          | secret02                                                              |
| Created       | 2018-03-20T00:59:44+00:00                                             |
| Status        | ACTIVE                                                                |
| Content types | {u'default': u'application/octet-stream'}                             |
| Algorithm     | aes                                                                   |
| Bit length    | 256                                                                   |
| Secret type   | symmetric                                                             |
| Mode          | cbc                                                                   |
| Expiration    | None                                                                  |
+---------------+-----------------------------------------------------------------------+
 
Tweet